function example(x: string | number, y: string | boolean) {
    if (x === y) {
        // ts know their type are all `string`
        x.toUpperCase();
        y.toUpperCase();
    } else {
        // string | number
        x;
        // string | boolean
        y;
    }
}

interface Container {
    value: number | null | undefined
}

function multiplyValue(container: Container, factor: number) {
    if (container.value != null) {
        // value is type of `number`
        container.value;
    }
}